import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsEnum, IsOptional, IsString, IsDate } from 'class-validator';
import { PagingReqDto } from '../../../../common/dtos/paging.req.dto';
import { LogAppender, LogLevel } from '../../../constants/log.constant';

export class GetSystemLogAdminReqDto extends PagingReqDto {
  @ApiProperty({ description: '开始时间' })
  @IsDate({ message: '开始时间格式不正确' })
  @Type(() => Date)
  readonly start: Date;

  @ApiProperty({ description: '结束时间' })
  @IsDate({ message: '结束时间格式不正确' })
  @Type(() => Date)
  readonly end: Date;

  @ApiProperty({ description: '日志级别', enum: LogLevel, required: false })
  @IsEnum(LogLevel, { message: '日志级别格式不正确' })
  @IsOptional()
  readonly level: LogLevel;

  @ApiProperty({ description: '日志类别', enum: LogAppender, required: false })
  @IsEnum(LogAppender, { message: '日志类别格式不正确' })
  @IsOptional()
  readonly appender: LogAppender;

  @ApiProperty({ description: '关键字', required: false })
  @IsString({ message: '关键字格式不正确' })
  @IsOptional()
  readonly keyword: string;
}
